package com.v9.system.controller;

import com.v9.common.dto.IdDto;
import com.v9.common.dto.PageInfoDto;
import com.v9.common.web.AbstractController;
import com.v9.system.domain.RoleType;
import com.v9.system.service.RoleTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author lunshi
 */
@RestController
@Tag(name = "工作流业务类型")
@RequestMapping(
        value = {"/system/role/type"},
        method = {RequestMethod.POST}
)
@Slf4j
public class RoleTypeController extends AbstractController {

    @Resource
    private RoleTypeService roleTypeService;

    @RequestMapping({"list"})
    @Operation(summary = "列表")
    public Page<RoleType> list(@RequestBody PageInfoDto dto) {
        return roleTypeService.queryByPage(new RoleType(),dto.getPageable());
    }

    @RequestMapping({"save"})
    @Operation(summary = "修改")
    public void save(@RequestBody RoleType info) {
        if(info.getId()==null){
            roleTypeService.insert(info);
            return;
        }
        roleTypeService.updateById(info);
    }

    @RequestMapping({"del"})
    @Operation(summary = "删除")
    public void del(@RequestBody IdDto dto) {
        roleTypeService.remove(dto.getId());
    }


}
